import java.io.*;
import java.util.Scanner;

public class Two_dimensionalDifference {
    static int N=1010;
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bufferedWriter=new BufferedWriter(new OutputStreamWriter(System.out));
        String []str1= bufferedReader.readLine().split(" ");
        int n=Integer.parseInt(str1[0]);
        int m=Integer.parseInt(str1[1]);
        int q=Integer.parseInt(str1[2]);
        int [][]a=new int[N][N];
        int [][]b=new int[N][N];
        for(int i=1;i<=n;i++){
            String []str2=bufferedReader.readLine().split(" ");
            for(int j=1;j<=m;j++){
                a[i][j]=Integer.parseInt(str2[j-1]);
                insert(i,j,i,j,a[i][j],b);
            }
        }
        while (q-->0){
            String []str3=bufferedReader.readLine().split(" ");
            int x1=Integer.parseInt(str3[0]);
            int y1=Integer.parseInt(str3[1]);
            int x2=Integer.parseInt(str3[2]);
            int y2=Integer.parseInt(str3[3]);
            int c=Integer.parseInt(str3[4]);
            insert(x1,y1,x2,y2,c,b);

        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
                bufferedWriter.write(b[i][j]+" ");
            }
            bufferedWriter.write("\n");
        }
        bufferedWriter.flush();;
        bufferedWriter.close();;
        bufferedReader.close();
    }
    public static void insert(int x1,int y1,int x2,int y2,int c,int [][]b){
        b[x1][y1]+=c;
        b[x2+1][y1]-=c;
        b[x1][y2+1]-=c;
        b[x2+1][y2+1]+=c;
    }
}
